#ifndef  SHINY_ERRORMANAGER_HPP
# define SHINY_ERRORMANAGER_HPP

# include <string>
# include <list>
# include <iostream>

namespace Shiny
{
  class Game;
  class ErrorManager
  {
    static ErrorManager* _errorManager;
  public:
    enum ErrorType
    {
      Warning   = 0,
      StopLevel = 1,
      StopGame  = 2
    };

    ErrorManager(Game& game) : _game(&game)
    {
      _errorManager = this;
    }

    static ErrorManager* Get(void);
    virtual void         AddError(const std::string& message, ErrorType type = Warning);
    bool                 Run(void);

  private:
    struct Error
    {
      Error(const std::string& message, ErrorType type) : message(message), type(type) {}

      const std::string message;
      const ErrorType   type;
    };

    void DisplayError(std::list<Error>::iterator error);
    
    std::list<Error> _errors;
    Game*            _game;

  protected:
    ErrorManager() {}
  };
  
  class BackupErrorManager : public ErrorManager
  {
    public:
      void AddError(const std::string& message, ErrorType type = Warning)
      {
	std::cerr << "ErrorManager: " << message << std::endl;
      }
  };
}

#endif